<template>
  <a-textarea
    class="custom-textarea"
    v-bind="instance"
    v-model="defaultValue"
    @input="updateVal($event.target.value)"
    @pressEnter="updateVal($event.target.value)">
  </a-textarea>
</template>

<script>

export default {
  props: {
    instance: Object // 配置
  },
  data() {
    return {
      defaultValue: ''
    }
  },
  watch: {
    instance: {
      handler(nVal) {
        Object.assign(this, { ...nVal }) // 把传入的参数，融合到this中
      },
      deep: true,
      immediate: true
    }
  },
  methods: {
    updateVal(value) {
      this.$emit('change', value)
    }
  }
}
</script>
